package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.PersonalHomeBean;
import com.lwj.liwanjia.bean.ZujiBean;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by 001 on 2017/9/9.
 */

public class ZuJiAdapter extends SuperBaseAdapter<ZujiBean.DataBean> {

    private Context mContext;

    public ZuJiAdapter(Context context, List<ZujiBean.DataBean> data) {
        super(context, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, ZujiBean.DataBean item, int position) {
        long time = item.getTime();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
        String strTime = dateFormat.format(time);
        Glide.with(mContext).load(item.getImgUrl()).into((ImageView) holder.getView(R.id.iv_photo));
        holder.setText(R.id.tv_time, strTime)
                .setText(R.id.tv_name, item.getCommodityName())
                .setText(R.id.tv_yongHuPinJia, item.getCommodityInfo())
                .setText(R.id.et_money, "¥" + item.getPrice());
    }

    @Override
    protected int getItemViewLayoutId(int position, ZujiBean.DataBean item) {
        return R.layout.adapter_zu_ji;
    }
}
